import config from '../config';
import routesMap from './containers/routesmap';

import { publicPath } from './common/js/global';

export default async providers => {
  if (config.dynamicRoutes) {
    const routesInfo = await providers.client.get(config.routesAPI);
    const routes = routesInfo.map(i => i);
    return routes;
  }

  const routes = [
    {
      component: routesMap.get('app'),
      routes: [
        { path: `${publicPath}/`, exact: true, component: routesMap.get('login') },
        { path: `${publicPath}/home`, exact: true, component: routesMap.get('home') },
        { path: `${publicPath}/user`, exact: true, component: routesMap.get('home') },
        { path: `${publicPath}/features`, exact: true, component: routesMap.get('home') },
        { path: `${publicPath}/login`, exact: true, component: routesMap.get('login') },
        { path: `${publicPath}/duplicateChecking`, exact: true, component: routesMap.get('duplicateChecking') },
        { path: `${publicPath}/customerDetails`, exact: true, component: routesMap.get('customerDetails') },
        { path: `${publicPath}/customer`, exact: true, component: routesMap.get('customerList') },
        { path: `${publicPath}/customer/add`, exact: true, component: routesMap.get('addCustomer') },
        { component: routesMap.get('404') }
      ]
    }
  ];

  return routes;
};
